package com.t.bricks.bussiness.init;


import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import com.t.bricks.model.Log;


@Component
public class NSOCRAware implements EnvironmentAware{	
	@Override
	public void setEnvironment(Environment environment) {
		
    	boolean ok = false;
    	try {
    		ok =  NSOCR.Engine.IsDllLoaded();
    	}catch(Exception e) {}
    	
    	/**
    	 * 检查OCR库是否加载
    	 */
		if (!ok) {
			Log.error("NSOCR library not loaded!");
			System.exit(1);
		}
		
		//NSOCR 授权,已开源授权码 AB2A4DD5FF2A
		NSOCR.Engine.Engine_SetLicenseKey("AB2A4DD5FF2A");
		NSOCR.Engine.Engine_Initialize();//多线程时先要调用初始化
		
		Log.info("NSOCR library loaded!");
	}
	

}
